package com.example.back.controller;

import com.example.back.model.Message;
import com.example.back.model.Route;
import com.example.back.service.MessageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author : 贾媛晴
 * @createTime : 2022/5/9 17:45
 */
@RestController
@Api(tags = "MessageController")
@CrossOrigin //允许跨域
public class MessageController {

    @Autowired
    MessageService messageService;

    @ApiOperation("写留言")
    @GetMapping("/inputMessage")
    public int insertMessage(String username,String message){
        return this.messageService.insertMessage(username,message);
    }

    @ApiOperation("留言")
    @GetMapping("/getMessage")
    public List<Message> selectAll(){
        List<Message> messageList = this.messageService.selectAll();
        return messageList;
    }
    @ApiOperation("个人中心留言")
    @GetMapping("/Center_getMessage")
    public List<Message> selectUsername(String username) {
        return this.messageService.selectUsername(username);
    }
}
